<!DOCTYPE html>

<html>
	<head>
		<meta charset="utf-8" />
		<title>Bootstrap-select</title>
		<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
		<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-select@1.13.12/dist/css/bootstrap-select.min.css">
	</head>

	<body>
	<div>
		<select class="selectpicker" id="system" data-style="btn-primary" data-width="300px" data-live-search="true">
			<option>system1</option>
			<option>system2</option>
			<option>system3</option>
		</select>
	</div>

	<div>
		<select id="select" class="selectpicker" title="请选择一个业务系统" data-style="btn-danger" data-width="30%"  data-size="5"  data-live-search="true">
			<option value="0">所有系统</option>
		</select>
	</div>


		<script src="https://cdn.jsdelivr.net/npm/jquery@1.12.4/dist/jquery.min.js"></script>
		<script src="https://cdn.jsdelivr.net/npm/bootstrap-select@1.13.12/dist/js/bootstrap-select.min.js"></script>
		<script src="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
		<script type="text/javascript">
			$(function () {
				$('#system').selectpicker();
				loadData();
			});
			function loadData(){
				$.ajax({
					type: "GET",
					url: 'data.json',
					data: {},
					timeout: 30000,
					aysnc: false,
					beforeSend: function () {

					},
					success: function (result) {
						var data = eval(result);
						for (let i = 0; i < data.length ; i++) {
							var system = $('#system');
							$("#select").append("<option value='"+data[i].id+"'>"+data[i].sys_name+"</option>");
						}
						$('#select').selectpicker('refresh');
					},
					error: function () {

					},
					complete: function () {

					}
				});
			};
		</script>
	</body>
</html>
